package com.jk.lesson3;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

/**
 * Created by Auser on 2016/11/8.
 */
public class ProcessFileTest {
    public static String processFile() throws IOException {
        try(
                BufferedReader br = new BufferedReader(new FileReader("D:/data.txt"))){
            return br.readLine();
        }
    }

    public static String processFile(BufferedReaderProcessor bufferedReaderProcessor) throws IOException {
        try(
                BufferedReader br = new BufferedReader(new FileReader("D:/data.txt"))){
                return bufferedReaderProcessor.process(br);
        }
    }

    public static void main(String...args){
        try {
            String content = processFile();
            System.out.println(content);
            String content2 = processFile(bufferedReader -> bufferedReader.readLine()+bufferedReader.readLine());
            System.out.println(content2);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
